package com.ruoyi.wb.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.wb.domain.WbPlanClassifyYearContentThree;
import com.ruoyi.wb.mapper.WbPlanClassifyYearContentThreeMapper;
import com.ruoyi.wb.service.IWbPlanClassifyYearContentThreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * 维保年度类三级Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-15
 */
@Service
public class WbPlanClassifyYearContentThreeServiceImpl implements IWbPlanClassifyYearContentThreeService
{
    @Autowired
    private WbPlanClassifyYearContentThreeMapper wbPlanClassifyYearContentThreeMapper;

    /**
     * 查询维保年度类三级
     * 
     * @param classifyContentId 维保年度类三级主键
     * @return 维保年度类三级
     */
    @Override
    public WbPlanClassifyYearContentThree selectWbPlanClassifyYearContentThreeByClassifyContentId(Long classifyContentId)
    {
        return wbPlanClassifyYearContentThreeMapper.selectWbPlanClassifyYearContentThreeByClassifyContentId(classifyContentId);
    }

    /**
     * 查询维保年度类三级列表
     * 
     * @param wbPlanClassifyYearContentThree 维保年度类三级
     * @return 维保年度类三级
     */
    @Override
    public List<WbPlanClassifyYearContentThree> selectWbPlanClassifyYearContentThreeList(WbPlanClassifyYearContentThree wbPlanClassifyYearContentThree)
    {
        return wbPlanClassifyYearContentThreeMapper.selectWbPlanClassifyYearContentThreeList(wbPlanClassifyYearContentThree);
    }

    /**
     * 新增维保年度类三级
     * 
     * @param wbPlanClassifyYearContentThree 维保年度类三级
     * @return 结果
     */
    @Override
    public int insertWbPlanClassifyYearContentThree(WbPlanClassifyYearContentThree wbPlanClassifyYearContentThree)
    {
        wbPlanClassifyYearContentThree.setCreateTime(DateUtils.getNowDate());
        return wbPlanClassifyYearContentThreeMapper.insertWbPlanClassifyYearContentThree(wbPlanClassifyYearContentThree);
    }

    /**
     * 修改维保年度类三级
     * 
     * @param wbPlanClassifyYearContentThree 维保年度类三级
     * @return 结果
     */
    @Override
    public int updateWbPlanClassifyYearContentThree(WbPlanClassifyYearContentThree wbPlanClassifyYearContentThree)
    {
        wbPlanClassifyYearContentThree.setUpdateTime(DateUtils.getNowDate());

        return wbPlanClassifyYearContentThreeMapper.updateWbPlanClassifyYearContentThree(wbPlanClassifyYearContentThree);
    }

    /**
     * 批量删除维保年度类三级
     * 
     * @param classifyContentIds 需要删除的维保年度类三级主键
     * @return 结果
     */
    @Override
    public int deleteWbPlanClassifyYearContentThreeByClassifyContentIds(Long[] classifyContentIds)
    {
        return wbPlanClassifyYearContentThreeMapper.deleteWbPlanClassifyYearContentThreeByClassifyContentIds(classifyContentIds);
    }

    /**
     * 删除维保年度类三级信息
     * 
     * @param classifyContentId 维保年度类三级主键
     * @return 结果
     */
    @Override
    public int deleteWbPlanClassifyYearContentThreeByClassifyContentId(Long classifyContentId)
    {
        return wbPlanClassifyYearContentThreeMapper.deleteWbPlanClassifyYearContentThreeByClassifyContentId(classifyContentId);
    }


    /**
     * 批量新增维保年度类三级
     */
    @Override
    public int batchAdd(List<WbPlanClassifyYearContentThree> wbPlanClassifyYearContentThrees) {
        return  wbPlanClassifyYearContentThreeMapper.batchAdd(wbPlanClassifyYearContentThrees);
    }

    /**
     * 批量修改维保年度类三级
     */
    @Override
    public int batchEdit(List<WbPlanClassifyYearContentThree> wbPlanClassifyYearContentThrees) {
        if (CollectionUtils.isEmpty(wbPlanClassifyYearContentThrees)){
            throw new RuntimeException("至少修改一条数据");
        }
        wbPlanClassifyYearContentThrees.forEach(item->{
            if (ObjectUtils.isEmpty(item.getClassifyContentId())){
                throw new RuntimeException("编号是必传的");
            }
        });
     return  wbPlanClassifyYearContentThreeMapper.batchEdit(wbPlanClassifyYearContentThrees);
    }

    @Override
    public List<WbPlanClassifyYearContentThree> selectWbPlanClassifyYearContentThreeListByClassifyYearContentIds(Long[] classifyYearContentIds) {
        return wbPlanClassifyYearContentThreeMapper.selectWbPlanClassifyYearContentThreeListByClassifyYearContentIds(classifyYearContentIds);
    }
}
